package com.hl.mapper;

import com.hl.pojo.FieldOfExcellence;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FieldOfExcellenceMapper {

    // 添加领域信息
    @Insert("insert into field_of_excellence (field_name) values (#{fieldName})")
    public Integer add(FieldOfExcellence fieldOfExcellence);

    // 查询所有领域信息（未删除）
    @Select("select * from field_of_excellence where del = 0")
    public List<FieldOfExcellence> findAll();

    // 根据ID删除领域信息（逻辑删除）
    @Update("update field_of_excellence set del = 1 where id = #{id}")
    public Integer deleteById(Integer id);

    // 根据领域名称查询领域信息
    @Select("select * from field_of_excellence where field_name = #{fieldName} and del = 0")
    public FieldOfExcellence findByFieldName(String fieldName);

    // 根据ID查询领域信息
    @Select("select * from field_of_excellence where id = #{id} and del = 0")
    public FieldOfExcellence findById(Integer id);

    // 更新领域信息
    @Update("update field_of_excellence set field_name=#{fieldName} where id=#{id}")
    public Integer update(FieldOfExcellence fieldOfExcellence);
}